<%@page language="java" pageEncoding="UTF-8"%>
<%@include file="/views/common/include/taglib.jsp"%>
		  <div style="top:130px;position:fixed;height:30px;font-size: 14px;font-family: '微软雅黑';margin-left:-236px;">
				当前位置：${sessionScope.currcent_position}
          </div>
		 <section >
            <section>
             <div class="panel" style="margin-top:21px;">
                	<div class="forword_area"></div>
					<div class="location">优惠券详情</div>
            <div class="serach-box" >
					 <div class="btn-group"style="margin-top: 2px;">
					 <input id="testname" type="hidden" value="${couponName}">
					 <select class="dropdown-menu" id="couponid" onchange="selectChange()" style="list-style-type: none;	height: 28px;min-width:123px;z-index: 99;margin-top:-1px;border: none;font-size: 14px;color: #919191;font-family: '微软雅黑';border-radius:10px;" >
		                         <option value="1"<c:if test="${not empty couponName}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;自定义搜索</option> 
		                         <option value="" <c:if test="${empty couponName }">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;请选择优惠券</option> 
			                      <c:forEach items="${couponInfos}" var="item" varStatus="cStatus">
										<option value="${item.id}"  <c:if test="${item.id == couponId}">selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;${item.name}</option>
								  </c:forEach>
		                    </select>
	                 </div>
			        <div id="sousuo"<c:if test="${empty couponName}"> style="float:left;height: 28px;margin-left: 12px;margin-top: 2px;display: none;"</c:if>
			        <c:if test="${not empty couponName}"> style="float:left;height: 28px;margin-left: 12px;margin-top: 2px;"</c:if>>
	                    <input id="couponName" type="text" maxlength="20" value="${(not empty couponName)? couponName : ''  }" class="input-sm" placeholder="优惠券名称">
	                  </div>
	                  
	                 <div class="btn-group"style="margin-top: 2px;">
		                    <%-- <input id="couponid" type="hidden" value="${couponDetail.id }"> --%>
	                   		<select class="dropdown-menu" id="couponstate" style="list-style-type: none;	height: 28px;min-width:123px;z-index: 99;margin-top:-1px;border: none;font-size: 14px;color: #919191;font-family: '微软雅黑';border-radius:10px;" >
		                        <option value="-1" <c:if test="${couponstate == -1 }"> selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;优惠券状态</option>
								<option value="2" <c:if test="${couponstate == 2 }"> selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;已下发</option>
								<option value="3" <c:if test="${couponstate == 3 }"> selected="selected"</c:if>>&nbsp;&nbsp;&nbsp;已使用</option>
		                    </select>
		              </div> 
		               <div class="form-control" style="margin-left: 0">
	                   		<div class="search" style="width:45px;margin-top: 2px;border-radius:0" onclick="getCouponDetailList();" >
	                   		<img src="${ctx }/images/table/search_second.png" style="margin-left:9px;margin-top:5px;">
	                   		</div>
               		   </div>
			           <div style="width:45px;height:27.5px;margin-left:10px;padding-top:7.5px;margin-top:2px;padding-left:10px;background-color:#ffaa00;
							color:white;cursor: pointer;float:left;" onclick="exportExcel();">导出</div>
						</div>
                </div>
        <div>
		 <table class="table" style="margin-top:19px;">
                     <thead>
                      <tr>
                       <th width="5%">序号</th>
                         <th width="10%">优惠券名称</th>
                        <th width="8%">优惠券编码</th>
                        <th width="10%">优惠券状态</th> 
                        <th width="7%">电话</th>
                        <!-- <th width="7%">手机IMEI号</th> -->
                       <!--  <th width="7%">用户账号</th> -->
                        <th width="10%">使用时间</th>
                        <th width="10%">过期时间</th>
                        <th width="10%">创建时间</th>
                      </tr>
                    </thead>
                    <tbody id="tableTbody">
	                      <c:forEach items="${couponDetail.list }" var="couponDetail" varStatus="couponDetailStatus">
	                      <tr>
	                      <td>${couponDetailStatus.index + 1 }</td>
	                        <td>${couponDetail.couponName}</td>
	                        <td>${couponDetail.code}</td>
	                        <td>
	                        <c:choose>
	                        <c:when test="${couponDetail.state == 1}">已生成</c:when>
	                        <c:when test="${couponDetail.state == 2}">已下发</c:when>
	                        <c:when test="${couponDetail.state == 3}">已使用</c:when>
	                        <c:otherwise> </c:otherwise>
	                        </c:choose></td>
	                        <td>${couponDetail.phone}</td>
	                        <%-- <td>${couponDetail.imei}</td> --%>
	                        <%-- <td>${couponDetail.userAccount}</td> --%>
	                        <td><fmt:formatDate value="${couponDetail.useTime}" pattern="yyyy-MM-dd"/></td>
	                        <td><fmt:formatDate value="${couponDetail.expireTime}" pattern="yyyy-MM-dd"/></td>
	                        <td><fmt:formatDate value="${couponDetail.createTime}" pattern="yyyy-MM-dd"/></td>
	                      </tr>
	                      </c:forEach>
                    </tbody>  
                      <tfoot>
		            	<tr>
		            	 <td colspan="8">
			                  <div>
			                   <%--  <div style="float:left;">
			                      <span class="total">合计 ${couponDetail.total} 条数据</span>               
			                    </div>  --%>
			                    <input id="total" type="hidden" value="${couponDetail.total}"/>
			                    <div style="float:right;  margin-right: 10px;margin-top: 29px"> 
				                  <div style="float:left;">                 
				                      <ul class="footer_ul">
				                      	<c:if test="${couponDetail.hasPreviousPage }">
				                        <li onclick="gotoPage(${currentPage-1 });"><a style="color:#37CED4">&lt;&lt;</a></li>
				                      	</c:if>
				                        <c:if test="${couponDetail.firstPage > 1}">
				                        	<li onclick="gotoPage(1);" style="border: 1px solid #9A9A9A;">
				                             	<a>1</a>
				                        	</li>
				                        	<c:if test="${couponDetail.firstPage > 2}">
				                        		...
				                        	</c:if>
				                      	</c:if>
				                        <c:forEach items="${couponDetail.navigatepageNums }" var="page">
				                        <li onclick="gotoPage(${page });" class="<c:if test="${currentPage == page }">active</c:if>" style="border: 1px solid #9A9A9A;">
				                             <a>${page}</a>
				                        </li>
				                        </c:forEach>
				                        <c:if test="${couponDetail.lastPage < couponDetail.pages}">
				                        	<c:if test="${couponDetail.firstPage < couponDetail.pages - 1}">
				                        		...
				                        	</c:if>
				                        	<li onclick="gotoPage(${couponDetail.pages});" style="border: 1px solid #9A9A9A;">
				                             	<a>${couponDetail.pages}</a>
				                        	</li>
				                      	</c:if>
				                        <c:if test="${couponDetail.hasNextPage }">
				                        <li><a onclick="gotoPage(${currentPage+1});" style="color:#37CED4">&gt;&gt;</a></li>
				                      	</c:if>
				                      </ul>
			                     </div>
		                   		<div style="float:left;  height: 30px;">
									<span style="color: #9A9A9A;">跳转到</span> 
									<input class="inputclass" id="pageNo" onkeydown="if(event.keyCode==13){event.keyCode=0;return false;}" 
									type="text" value="${currentPage }" style="width:26px;height:28px"onkeyup = "checInputNum(this)">
									<span style="color: #9A9A9A;">页</span> 
									<span class="buttonclass" id="J_JumpTo" onclick="gotoCouponDetailPage(null);"><a>GO</a></span>
								</div>
			                 </div>
			                 </div>
							</td>
						</tr>
					</tfoot>
                    </table>
		</div> 
	  </section>
	  </section>
	<script
		src="${ctx}/js/controllers/coupon/CouponDetailController.js"
		type="text/javascript">
	</script>
	<script type="text/javascript">
		var ctx = '${ctx}';
		setCtx(ctx);
		/* $(function(){
		if($("#testname").val() != null){
			$("#sousuo").show();
		}else{
			$("#sousuo").hide();
		}
			
		}); */
		function selectChange(){
			if($("#couponid option:selected").val() == 1){
				$("#sousuo").show();
			}else{
				$("#couponName").val("");
				$("#sousuo").hide();
			}
		}
		
	</script>    
